Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FullAncillaAllocation for backends witout a coupling map #10240

Merged
merged 8 commits into from
Jun 9, 2023
Merged

FullAncillaAllocation for backends witout a coupling map #10240

merged 8 commits into from
Jun 9, 2023

Conversation

eggerdj
Copy link
Contributor

@eggerdj eggerdj commented Jun 7, 2023

Summary

The transpiler can transpile to a given target. In some situations there is no coupling map. This can occur at the beginning of device bring-up when the two-qubit gates have not yet been calibrated. In the absence of a coupling map the FullAncillaAllocation fails to enlarge the circuit to a number of total qubits that match the number of qubits specified by the target. This PR fixes this behavior.

Details and comments

The behavior is fixed by catching the case when coupling map is None. In this case we refer to the number of qubits specified by the target. The test illustrates the desired behavior.

@eggerdj eggerdj requested a review from a team as a code owner June 7, 2023 12:18
@qiskit-bot
Copy link
Collaborator

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core

@eggerdj eggerdj changed the title * Added support for targets without a coupling map. FullAncillaAllocation for backends witout a coupling map Jun 7, 2023
@coveralls
Copy link

coveralls commented Jun 7, 2023

Pull Request Test Coverage Report for Build 5222217308

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.07%) to 85.922%

Files with Coverage Reduction New Missed Lines %
crates/accelerate/src/sabre_swap/mod.rs 1 99.77%
crates/qasm2/src/expr.rs 1 93.76%
qiskit/extensions/quantum_initializer/squ.py 2 80.0%
crates/qasm2/src/lex.rs 3 90.63%
Totals Coverage Status
Change from base Build 5201330574: 0.07%
Covered Lines: 71270
Relevant Lines: 82947

💛 - Coveralls

@@ -85,6 +85,11 @@ def run(self, dag):
idle_physical_qubits = [
q for q in self.coupling_map.physical_qubits if q not in physical_bits
]
else:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this branching causes an edge case. When you partly define two qubit gate on your system it will give you imperfect coupling map and you cannot expand the single qubit experiment circuit as you expect. This if-clause should be conditioned on target.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nkanazawa1989 can you make a suggestion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant

if self.target:
    idle_physical_qubits = [
        q for q in range(self.target.num_qubits) if q not in physical_bits
    ]
elif self.coupling_map:
    idle_physical_qubits = [
        q for q in self.coupling_map.physical_qubits if q not in physical_bits
    ]
else:
    raise SomeError

By doing this you can always expand circuit to full physical qubits widths.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, see change here: f5350b5

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, thanks for fixing this. I just left some inline suggestions on the release notes formatting and wording. Other than that I think this is ready to merge

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the quick update.

@mtreinish mtreinish added this pull request to the merge queue Jun 9, 2023
@mtreinish mtreinish added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Jun 9, 2023
Merged via the queue into Qiskit:main with commit b36609b Jun 9, 2023
@eggerdj eggerdj deleted the full_ancilla_allocation branch June 12, 2023 11:54
thspreetham98 pushed a commit to thspreetham98/qiskit-terra that referenced this pull request Jun 19, 2023
* * Added support for targets without a coupling map.

* * Removed restrictive raise.

* * Changed order of target and coupling map

* Apply suggestions from code review

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants